#ifndef SEQUENCERUNFRAME_H
#define SEQUENCERUNFRAME_H

#include <QFrame>
#include <QMenu>
#include "experiment.h"
#include "sourcemanage.h"
#include <QThread>
#include <QTreeWidgetItem>

namespace Ui {
class SequenceRunFrame;
}

class SequenceRunFrame : public QFrame
{
    Q_OBJECT
    
public:
    explicit SequenceRunFrame(QWidget *parent = 0,Experiment* pExperiment=NULL);
    ~SequenceRunFrame();
    void LoadData();

private slots:
    void on_toolButton_Update_clicked();//实验编辑后加入序列时刷新实验序列，序列实验结果更新时刷新实验编辑处的结果  
    void on_toolButton_Start_clicked();
    void on_toolButton_Stop_clicked();
    void on_toolButton_SkipSample_clicked();
    void on_toolButton_SkipExp_clicked();
    void OnCustomContextMenuRequested(const QPoint &pos);
    void on_actionDel_triggered();
    void on_actionDelAll_triggered();
    void OnExpStateChanged(QString);
    void OnResponseTimeout(uchar,uchar);
    void OnWaitIn(int type);
    void OnExpScanChanged(QString path,int sampleIndex,int preIndex,int mainIndex);
    void OnExpFinish(int);
    void UpdateResult(QList<ExpRawData>);

    void on_pushButton_OpenVacuum_clicked();
    void on_pushButton_CloseVacuum_clicked();
    void on_pushButton_OpenPlasma_clicked();
    void on_pushButton_ClosePlasma_clicked();   
    void OnStateChanged(QString);
    void OnWorkFlowFinished(int);   
    void on_actionOpen_triggered();

private:
    Ui::SequenceRunFrame *ui;
    Experiment* pExperiment;
    ExpSample *pExpSample;
    QMenu *pMenu;
    QTreeWidgetItem *pItem1;

    NetDealwith *pNetDealwith;
    QThread *pThread;

    QStringList testLogs;
    int runningState;//1：打开真空 2：关闭真空 3：打开等离子体 4：关闭等离子体
    int expRunState;

    void UpdateButton(int state);
    void UpdateExpButton(int state);

    void SetExpScanState(QTreeWidgetItem *,int state);
    void SetSampleScanState(QTreeWidgetItem *,int state);
    void SetPreScanState(QTreeWidgetItem *,int state);
    void SetMainScanState(QTreeWidgetItem *,int state);
};

#endif // SEQUENCERUNFRAME_H
